﻿<%@ Page Language="C#" MasterPageFile="~/CmsMaster.Master" AutoEventWireup="true" CodeBehind="ApproveTimesheet.aspx.cs" Inherits="ContractManagementSystem.Presentation.TimesheetManagement.ApproveTimesheet" Title="Timesheet Manager >>> Approve Timesheet" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" type="text/css" href="../../Styles/ClientStyle.css" />
    <script type = "text/javascript" language = "javascript" src = "../../JavaScript/JsLibrary.js"> </script>
    
    <script type = "text/javascript" language = "javascript" src = "../../JavaScript/jquery.js"> </script>
    <script type = "text/javascript" language = "javascript" src = "../../JavaScript/menu.js"> </script>
    
    <!---validate form--->
    <link href="../../JavaScript/validationEngine/css/template.css" rel="stylesheet"
          type="text/css" />
    <link href="../../JavaScript/validationEngine/css/validationEngine.jquery.css" rel="stylesheet"
          type="text/css" />
    <script src="../../JavaScript/validationEngine/js/jquery-1.6.min.js" type="text/javascript"> </script>   

    <script src="../../JavaScript/validationEngine/js/jquery.validationEngine-en.js"
            type="text/javascript"> </script>

    <script src="../../JavaScript/validationEngine/js/jquery.validationEngine.js" type="text/javascript"> </script>
    
    <!--Jquery dialog form -->    
    <link href="../../JavaScript/validationEngine/css/ui-lightness/jquery-ui-1.7.2.custom.css"
          rel="stylesheet" type="text/css" />

    <script src="../../JavaScript/validationEngine/js/jquery-ui-1.7.2.custom.min.js"
            type="text/javascript"> </script> 
    
    <script type="text/javascript">
    	$(document).ready(function() {
    		//setup new person dialog
    		$('#newReason').dialog({
    				autoOpen: false,
    				draggable: true,
    				modal: true,
    				title: "Add New Reason",
    				open: function(type, data) {
    					$(this).parent().appendTo("form");
    				}
    			});

    		//setup edit person dialog
    		$('#editReason').dialog({
    				autoOpen: false,
    				draggable: true,
    				modal: true,
    				title: "Edit Reason",
    				open: function(type, data) {
    					$(this).parent().appendTo("form");
    				}
    			});
    	});

    	function showDialog(id) {
    		$('#' + id).dialog("open");
    	}

    	function closeDialog(id) {
    		$('#' + id).dialog("close");
    	}

    </script>
    


</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentHolder" runat="server">
    <div class="CPF">
    
        <div id="CPFalertMessage" class="CPFerror">
            <asp:Label runat="server" ID="labelResult" CssClass="CPFResultMessage" Visible="false" ></asp:Label>
        </div> 
    
        <div class="CPFSearch">
            <div class="CPFrow">
                <div class="CPFcols">
                    <label>Contract</label>
                </div>
                <div class="CPFcols">
                    <asp:DropDownList runat="server" ID="dropContract" Height="20px" Width="150px"/>
                </div>
                <div class="CPFcols">
                    <label>Status</label>
                </div>
                <div class="CPFcols">
                    <asp:DropDownList runat="server" ID="dropStatus" Height="20px" Width="100px">
                        <asp:ListItem></asp:ListItem>
                        <asp:ListItem>Pending</asp:ListItem>
                        <asp:ListItem>Rejected</asp:ListItem>
                        <asp:ListItem>Approved</asp:ListItem>
                    </asp:DropDownList>
                </div>
                <div class="CPFcols">
                    <asp:Button runat="server" ID="buttonFilter" Text="Filter" CssClass="CPFButton1" OnClick="FilterClick"/>
                </div>

            </div>

        </div>
    
        <div class="clear"></div>
        <asp:ScriptManager ID="mainScriptManager" runat="server"></asp:ScriptManager>
    
        <asp:UpdatePanel ID="upGrid" UpdateMode="Conditional" runat="server">
            <ContentTemplate>
            
                <asp:ListView runat="server" ID="approveTimesheet" 
                              onitemcommand="ApproveTimesheetItemCommand">
                
                    <LayoutTemplate>
                        <table class="repeaterTable">
                            <tr class="tableHeader">
                            
                                <td>Contract Number</td>
                                <td>OnDate</td>
                                <td>Time</td>
                                <td>Description</td>
                                <td>Status</td>
                                <td>Reason</td>
                                <td>Contractor</td>
                                <td>Approve</td>
                                <td>Reject</td>
                            </tr>
                            <tr id="itemPlaceholder" runat="server"></tr>
                        </table>
                    
                        <table class="CPFrepeaterTable" >
                            <tr class="CPFtableHeader">
                                <td class="CPFPage">
                                    <asp:DataPager runat="server" ID="ItemDataPager" PageSize="10">
                                        <Fields>
                                            <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowNextPageButton="false" ButtonCssClass="CPFNumPage" />
                                            <asp:NumericPagerField ButtonCount="5" CurrentPageLabelCssClass="CPFCurrentNumPage" NumericButtonCssClass="CPFNumPage" />
                                            <asp:NextPreviousPagerField ShowLastPageButton="true" ShowPreviousPageButton="false" ButtonCssClass="CPFNumPage"/>
                                        </Fields>                    
                                    </asp:DataPager>     
                                </td>
                            </tr>           
                        </table>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <tr class="CPFTr">

                            <td>
                                <asp:Label runat="server" ID="ContractTitle" Width="100" Height="20"><%#Eval("ContractNumber")%></asp:Label>
                            </td>
                            <td class="CPFtd">
                                <asp:Label runat="server" ID="OnDate" Width="70" Height="20"><%#DateTime.Parse(Eval("OnDate").ToString()).ToString("MM/dd/yyyy")%></asp:Label>
                            </td>
                            <td class="CPFtd">
                                <asp:Label runat="server" ID="Time" Width="20" Height="20"><%#Eval("Time")%></asp:Label>
                            </td>
                            <td>
                                <asp:Label runat="server" ID="Description" Width="180" Height="20"><%#Eval("Description")%></asp:Label>
                            </td>
                            <td class="CPFtd">
                                <asp:Label runat="server" ID="Status" Width="50" Height="20"><%#Eval("Status")%></asp:Label>
                            </td>
                            <td>
                                <asp:LinkButton runat="server" ID="Reason"  Width="180" OnClick="LinkEditReason" OnClientClick="showDialog('editReason');" CommandArgument='<%#Eval("TimesheetDetailId")%>' Text='<%#Eval("reason")%>' ></asp:LinkButton>
                            </td>
                            <td>
                                <asp:Label runat="server" ID="CcontractorLabel"  Width="130"><%#Eval("Contractor")%></asp:Label>
                            </td>
                        
                            <td class="CPFtdDelete">
                                <asp:LinkButton ID="LinkButtonApprove" runat="server"  CommandName="Approve" CommandArgument='<%#Eval("TimesheetDetailId")%>'>
                                    <asp:Image ID="Image1" runat="server" CssClass="CPFdelete" ImageUrl="../../Images/approve.png"></asp:Image>
                                </asp:LinkButton>
                            </td>
                        
                            <td class="CPFtdDelete">
                                <asp:LinkButton ID="LinkButtonReject" runat="server" OnClientClick="showDialog('newReason');"  CommandName="Reject" CommandArgument='<%#Eval("TimesheetDetailId")%>'>
                                    <asp:Image ID="Image2" runat="server" CssClass="CPFdelete" ImageUrl="../../Images/reject.png"></asp:Image>
                                </asp:LinkButton>
                            </td>
                        </tr>    
                    </ItemTemplate>
                
                    <EmptyDataTemplate>
                        <table class="repeaterTable">
                            <tr class="tableHeader">
                            
                                <td>Contract Number</td>
                                <td>OnDate</td>
                                <td>Time</td>
                                <td>Description</td>
                                <td>Status</td>
                                <td>Reason</td>
                                <td>Contractor</td>
                                <td>Approve</td>
                                <td>Reject</td>
                            </tr>
                            <tr>
                                <td colspan="9" class="CPFNotData">
                                    <label style="color: #FF0000; font-size: 18px;">Sorry ! no data found</label>
                                </td>                            
                            </tr>                        
                        </table>

                    </EmptyDataTemplate>
                
                </asp:ListView>
        
            </ContentTemplate>
        </asp:UpdatePanel>            
            
        <div id='newReason'>
            <asp:UpdatePanel ID="upNewUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
                <ContentTemplate>
                
                    <asp:TextBox runat="server" ID="textTimesheetId" Width="161px" Visible="False"></asp:TextBox>
                    <asp:TextBox ID="textNewReason" runat="server" TextMode="MultiLine" Width="260px" Height="100px" CssClass="validate[required]"></asp:TextBox>
                    <%--<asp:RequiredFieldValidator ID="reqName1" ControlToValidate="textNewReason" ValidationGroup="Add" runat="server" ErrorMessage="Reason is required"></asp:RequiredFieldValidator>--%>
                    <asp:Button ID="ButtonAddReason" OnClick="AddReasonClick"  runat="server" Text="Save"  />
            
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>       
     
        <div id='editReason'>
            <asp:UpdatePanel ID="upEditUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
                <ContentTemplate>
                    <label>TimesheetId:</label>
                    <asp:Label runat="server" ID="labelId"></asp:Label>
                    <asp:TextBox ID="textEditReason" runat="server" TextMode="MultiLine" Width="260px" Height="100px" CssClass="validate[required]" ></asp:TextBox>
                    <%--<asp:RequiredFieldValidator ID="reqName1" ControlToValidate="textNewReason" ValidationGroup="Add" runat="server" ErrorMessage="Reason is required"></asp:RequiredFieldValidator>--%>
                    <asp:Button ID="Button1" OnClick="EditReasonClick"  runat="server" Text="Save"  />
            
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>

    <!----------------->
    <script type="text/javascript">
        jQuery(document).ready(function() {
        	jQuery("#aspnetForm").validationEngine();
        });
    </script>
    <!----------------->
</asp:Content>